
Type CalCoreMaterial

	Field m_ambientColor:CalColor
	Field m_diffuseColor:CalColor
	Field m_specularColor:CalColor
	Field m_shininess:Float
	Field m_vectorMap:CalMap[]
	Field m_userData:Object
	Field m_name:String
	Field m_filename:String
	
	
	Method New()
	
		m_ambientColor = New CalColor
		m_diffuseColor = New CalColor
		m_specularColor = New CalColor
		m_vectorMap = New CalMap[0]
	End Method

	Method getAmbientColor:CalColor()
		Return m_ambientColor
	End Method
	
	Method getDiffuseColor:CalColor()
		Return m_diffuseColor
	End Method
	
	Method getMapCount:Int()
		Return m_vectorMap.length
	End Method
	
	Method getMapFilename:String(mapId:Int)
		If mapId < 0 Or mapId >= m_vectorMap.length Then
			Return ""
		EndIf
	
		Local map:CalMap = m_vectorMap[mapId]
		If map = Null Then
			Return ""
		Else
			Return map.filename		
		EndIf
	End Method

	Method getMapUserData:Object(mapId:Int)
		If mapId < 0 Or mapId >= m_vectorMap.length Then
			Return Null
		EndIf
	
		Local map:CalMap = m_vectorMap[mapId]
		If map = Null Then
			Return Null
		Else
			Return map.userData	
		EndIf			
	End Method
	
	Method getShininess:Float()
		Return m_shininess
	End Method
	
	Method getSpecularColor:CalColor()
		Return m_specularColor
	End Method
	
	Method getUserData:Object()
		Return m_userData
	End Method

	Method getVectorMap:CalMap[]()
		Return m_vectorMap
	End Method

	Method getFilename:String()
		Return m_filename
	End Method

	Method getName:String()
		Return m_name
	End Method
	
	Method reserve:Byte(mapCount:Int)
		m_vectorMap = New CalMap[mapCount]
		Return True
	End Method

	Method setAmbientColor(ambientColor:CalColor)
		m_ambientColor = CalColor.FromColor(ambientColor)
	End Method
	
	Method setDiffuseColor(diffuseColor:CalColor)
		m_diffuseColor = CalColor.FromColor(diffuseColor)
	End Method
	
	Method setMap:Byte(mapId:Int, map:CalMap)
		If mapId < 0 Or mapId >= m_vectorMap.length Then
			Return False
		EndIf
	
		m_vectorMap[mapId] = map
		Return True	
	
	End Method
	
	Method setMapUserData:Byte(mapId:Int, userData:Object)
		If mapId < 0 Or mapId >= m_vectorMap.length Then
			Return False
		EndIf
	
		Local map:CalMap = m_vectorMap[mapId]
		If map = Null Then
			Return False
		EndIf
		
		map.userData = userData		
		Return True
	End Method

	Method setShininess(shininess:Float)
		m_shininess = shininess
	End Method
	
	Method setSpecularColor(specularColor:CalColor)
		m_specularColor = CalColor.FromColor(specularColor)
	End Method
	
	Method setFilename(filename:String)
		m_filename = filename
	End Method
	
	
	Method setName(name:String)
		m_name = name
	End Method
	
	
	Method setUserData(userData:Object)
		m_userData = userData
	End Method

End Type

Type CalColor

	Field red:Float,green:Float,blue:Float,alpha:Float

	Method New()
		red = 0
		green = 0
		blue = 0
		alpha = 0
	End Method
	
	Function FromColor:CalColor(c:CalColor)
		Local cc:CalColor = New CalColor
		cc.red = c.red
		cc.green = c.green
		cc.blue = c.blue
		cc.alpha = c.alpha
		Return cc
	End Function
	
	Function FromValues:CalColor(r:Float,g:Float,b:Float,a:Float)
		Local cc:CalColor = New CalColor
		cc.red = r
		cc.green = g
		cc.blue = b
		cc.alpha = a
		Return cc
	End Function
	

End Type

Type CalMap

	Field filename:String
	Field userData:Object
	
	

End Type
